<template>
	<view class="container">
		<view class="tab_box">
			<u-tabs :list="list" :is-scroll="false" :current="current" @change="change" active-color="#40AE36"
				bar-height="6" bar-width="40"></u-tabs>
		</view>
		<view class="content">
			<view class="list" v-for="(item,index) in scoreList" :key="index">
				<view class="left">
					<view class="big">{{item.remark}}</view>
					<view class="time">{{item.create_time}}</view>
				</view>
				<view class="right">
					{{item.score>0?`+${item.score}`:`-${item.score}`}} <text>积分</text>
				</view>
			</view>
		</view>
		<u-loadmore :status="status" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					name: '收入'
				}, {
					name: '支出'
				}],
				current: 0,
				scoreList: [],
				page: 1,
				pageSize: 10,
				total: 1,
				count: 1,
				status: 'loadmore',
			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			getData() {
				let type = '1'
				if (this.list[this.current] == '收入') {
					type = '1'
				} else {
					type = '2'
				}
				this.$allApi.getScoreInfo({
					page: this.page,
					pagesize: this.pageSize,
					type: type,
				}).then(res => {
					if (this.page == 1) {
						this.scoreList = res.data.data
						this.total = res.data.total
						this.count = Math.ceil(Number(this.total) / 10)
					} else {
						this.scoreList = [...this.scoreList, ...res.data.data]
					}
					if (this.page >= this.count) {
						this.status = 'nomore'
					} else {
						this.status = 'loadmore'
					}
				})
			},
			change(index) {
				this.current = index;
				this.getData()
			},
		}
	}
</script>

<style scoped lang="scss">
	.list {
		width: 710rpx;
		height: 104rpx;
		background: #fff;
		border-radius: 10rpx;
		padding: 0 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.time {
			font-size: 20rpx;
			color: #999;
		}

		.right {
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 36rpx;
			font-weight: bold;
			color: #40AE36;

			text {
				font-size: 20rpx;
				color: #333;
				font-weight: normal;
				margin-left: 20rpx;
			}
		}
	}

	.container {
		min-height: 100vh;
		background: #F8F8F8;
	}

	.content {
		padding: 20rpx;
	}
</style>